
<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>药品出入库信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script type="text/javascript" th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <input name="id" th:value="${owinfo?.id}" type="hidden">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>药品名称
                </label>
                <div class="layui-input-block">
                    <select name="dname" id="dname"></select>
                </div>
            </div>
           <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>出/入库
                </label>
                <div class="layui-input-block" th:style="'display:' + @{(${owinfo?.type != null} ? 'none' : '')} + ''">
                  <input type="radio" name="type" value="出库" title="出库">
                  <input type="radio" name="type" value="入库" title="入库">
                </div>
               <div class="layui-input-block" th:style="'display:' + @{(${owinfo?.type == null} ? 'none' : '')} + ''">
                   <input type="text" name="type" class="layui-input" readonly th:value="${owinfo?.type}">
               </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>数量
                </label>
                <div class="layui-input-block">
                    <input type="text" th:value="${owinfo?.count}" name="count" lay-verify="required"
                           autocomplete="off" class="layui-input" placeholder="请输入药品数量">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>操作人
                </label>
                <div class="layui-input-block">
                    <input type="text" th:value="${owinfo?.operator}" name="operator" lay-verify="required"
                           autocomplete="off" class="layui-input" placeholder="请输入操作人">
                </div>
            </div>
            <div class="layui-form-item layui-hide">
                <input type="button" lay-submit lay-filter="LAY-front-submit" id="LAY-front-submit" value="确认">
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form'], function() {
        $ = layui.jquery;
        var form = layui.form;

        //获取当前药品名称
        var currentDruginfo = '[[${owinfo?.dname}]]';
        $.ajax({
           url:'/druginfo/druginfoList',
           dataType:'json',
           success:function (data){
               $('#dname').prepend('<option value="">请选择药品名称</option>')
               for (var i = 0; i < data.length; i++){
                   if(currentDruginfo == data[i].name){
                       $('#dname').append('<option selected value="'+data[i].name+'">'+data[i].name+'</option>');
                   }else {
                       $('#dname').append('<option value="'+data[i].name+'">'+data[i].name+'</option>');
                   }

               }
               form.render(); //下拉列表渲染，把内容加载进去
           }
        });
    });
</script>
</body>

</html>
